//
//  ITNavigationController.m
//  coderSinaWeiBo24
//
//  Created by 张雪雪 on 16/3/25.
//  Copyright © 2016年 www.xue.com. All rights reserved.
//

#import "ITNavigationController.h"

@interface ITNavigationController ()

@end

@implementation ITNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    NSString *title = @"返回";
    NSInteger count = self.childViewControllers.count;
    //如果执行到的这个地方，判断里面有一个控制器的话，代表当前要往导航控制器里面的push的是滴二个控制器
    if (count > 1) {
        if (count == 1) {
            title = [[self.childViewControllers firstObject] title];
        }
        //设置在push的时候隐藏底部tabbar
        viewController.hidesBottomBarWhenPushed = YES;
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImageName:@"navigationbar_back_withtext" title:title target:self action:@selector(back)];
        
    }
    
    [super pushViewController:viewController animated:animated];
}

-(void)back{

    [self popViewControllerAnimated:YES];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
